<!DOCTYPE html>
<html lang="en"  xmlns:th="http://www.thymeleaf.org">
<head>
  <meta charset="UTF-8">
  <title>根据id获取的详细信息放到这里</title>
  <link rel="stylesheet" href="../layuimini/lib/layui-v2.6.3/css/layui.css" media="all">
  <link rel="stylesheet" href="../layuimini/css/public.css" media="all">
</head>
<body>
<form method="post" class="layui-form" action="">
  <div class="layui-form-item" th:each="e:${ct}">
    <div class="layui-inline">
      <div class="layui-input-bolck">
        <input th:value="${e.id }" name="id" type="hidden" autocomplete="off" class="layui-input" />
      </div>
    </div>
    <br/>
    <div class="layui-inline">
      <label class="layui-form-label">合同名称</label>
      <div class="layui-input-inline">
        <input type="text" th:value="${e.contractname}" name="contractname" autocomplete="off" class="layui-input" />
      </div>
      <label class="layui-input-inline" style="color: red;margin-top: 8px;display: none" id="onename">请输入合同名称</label>
    </div>
    <br/>
    <div class="layui-inline">
      <label class="layui-form-label">甲方名称</label>
      <div class="layui-input-inline">
        <input type="text" th:value="${e.contractnail }" readonly="readonly" name="contractnail" autocomplete="off" class="layui-input">
      </div>
    </div>
    <br/>
    <div class="layui-inline">
      <label class="layui-form-label">乙方名称</label>
      <div class="layui-input-inline">
        <input type="text" th:value="${e.contractb }" readonly="readonly" name="contractb" autocomplete="off" class="layui-input">
      </div>
    </div>
    <br/>
    <div class="layui-inline">
      <label class="layui-form-label">合同金额</label>
      <div class="layui-input-inline">
        <input type="text" th:value="${e.contractmoney }" name="contractmoney" autocomplete="off" class="layui-input">
      </div>
      <label class="layui-input-inline" style="color: red;margin-top: 8px;display: none" id="twoname">请输入合同金额</label>
    </div>
  </div>
  <div calss="layui-form-item">
    <div class="layui-input-block">
      <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认保存</button>
    </div>
  </div>
</form>
<script src="../layuimini/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script>
  layui.use(['form'], function () {
    var form = layui.form;
    var layer = layui.layer;
    var $ = layui.$;

    //监听提交
    form.on('submit(saveBtn)', function (data) {
      if(data.field.contractname=='' || data.field.contractname==null){
        $("#onename").show();
        return false;
      }
      $(":input[name='contractname']").bind("click",function (){
        $("#onename").hide();
      })
      if(data.field.contractmoney=='' || data.field.contractmoney==null){
        $("#twoname").show();
        return false;
      }
      $(":input[name='contractmoney']").bind("click",function (){
        $("#twoname").hide();
      })
      $.post('/user/updaedit',data.field,function(res){
        if(res.data==="success"){
          var iframeIndex = parent.layer.getFrameIndex(window.name);
          parent.layer.close(iframeIndex);
          //通过父页面去重新加载表格
          parent.layui.table.reload('table-user');
          parent.layei.msg(res.msg);
          this.close();
        }
      })
      return false;
    });

  });
</script>
</body>
</html>